package com.informatics.polymer.client.PolymerTemplates;

import org.restlet.gwt.Callback;
import org.restlet.gwt.Client;
import org.restlet.gwt.data.Form;
import org.restlet.gwt.data.Protocol;
import org.restlet.gwt.data.Request;
import org.restlet.gwt.data.Response;
import org.restlet.gwt.resource.Representation;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.TextBox;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.Side;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import com.smartgwt.client.widgets.tab.Tab;
import com.smartgwt.client.widgets.tab.TabSet;

/**
 * Class to implement a panel to build random copolymers.
 * @author ed
 * @version 1.0
 */
public class RandomCopolymerPanel extends SectionStack implements InitializePolymerPanels {
	/**
	 * Integer representing the number of times the build button has been pressed.
	 */
	private int counter=-1;
	/**
	 * XML string representation of the built random copolymer;
	 */
	private String randomCopolymerBuilt;
	/**
	 * Probability of repeat unit A after A.
	 */
	private double pAA;
	/**
	 * Probability of termination after A.
	 */
	private double pTA;
	/**
	 * Probability of repeat unit B after A.
	 */
	private double pAB;
	/**
	 * Probability of repeat unit A after B.
	 */
	private double pBA;
	/**
	 * Probability of repeat unit B after B.
	 */
	private double pBB;
	/**
	 * Probability of termination after B.
	 */
	private double pTB;
	/**
	 * Constructs default RandomCopolymerPanel
	 */
	public RandomCopolymerPanel(){
		setUpPanel();
	}
	@Override
	public TabSet detailsPanel() {
		final TabSet randomCopolymerDetails = new TabSet();
		randomCopolymerDetails.setBackgroundColor("#F0F0F0");
		randomCopolymerDetails.setTabBarPosition(Side.TOP);
		randomCopolymerDetails.setWidth(1000);
		randomCopolymerDetails.setHeight(200);
		Tab pAATab = new Tab("pAA");
		Canvas pAACanvas = new Canvas();
		pAACanvas.setBackgroundColor("#F0F0F0");
		final TextBox pAATextBox = new TextBox();
		pAACanvas.addChild(pAATextBox);
		pAATab.setPane(pAACanvas);
		Tab pABTab = new Tab("pAB");
		Canvas pABCanvas = new Canvas();
		pABCanvas.setBackgroundColor("#F0F0F0");
		final TextBox pABTextBox = new TextBox();
		pABCanvas.addChild(pABTextBox);
		pABTab.setPane(pABCanvas);
		Tab pTATab = new Tab("pTA");
		Canvas pTACanvas = new Canvas();
		pTACanvas.setBackgroundColor("#F0F0F0");
		final TextBox  pTATextBox = new TextBox();
		pTACanvas.addChild(pTATextBox);
		pTATab.setPane(pTACanvas);
		//pBA
		Tab pBATab = new Tab("pBA");
		Canvas pBACanvas = new Canvas();
		pBACanvas.setBackgroundColor("#F0F0F0");
		final TextBox pBATextBox = new TextBox();
		pBACanvas.addChild(pBATextBox);
		pBATab.setPane(pBACanvas);
		//pBB
		Tab pBBTab = new Tab("pBB");
		Canvas pBBCanvas = new Canvas();
		pBBCanvas.setBackgroundColor("#F0F0F0");
		final TextBox pBBTextBox = new TextBox();
		pBBCanvas.addChild(pBBTextBox);
		pBBTab.setPane(pBBCanvas);
		//pTB
		Tab pTBTab = new Tab("pTB");
		Canvas pTBCanvas = new Canvas();
		pTBCanvas.setBackgroundColor("#F0F0F0");
		final TextBox pTBTextBox = new TextBox();
		pTBCanvas.addChild(pTBTextBox);
		pTBTab.setPane(pTBCanvas);
		Tab tTab2 = new Tab("Torsion Angle");
		Canvas tab2Canvas = new Canvas();
		tab2Canvas.setBackgroundColor("#F0F0F0");
		final TextBox tbTorsionAngle = new TextBox();
		tbTorsionAngle.setTitle("Torsion Angle");
		tab2Canvas.addChild(tbTorsionAngle);
		tTab2.setPane(tab2Canvas);
		Tab tTab3 = new Tab("Repeat Unit A");
		Canvas tab3Canvas = new Canvas();
		tab3Canvas.setBackgroundColor("#F0F0F0");
		final TextBox tbRepeatUnit = new TextBox();
		tbRepeatUnit.setTitle("Repeat Unit");
		tab3Canvas.addChild(tbRepeatUnit);
		tTab3.setPane(tab3Canvas);
		//Add repeat unit B
		Tab repeatUnitBTab = new Tab("Repeat Unit B");
		Canvas repeatUnitBCanvas = new Canvas();
		repeatUnitBCanvas.setBackgroundColor("#F0F0F0");
		final TextBox repeatUnitBTextBox = new TextBox();
		repeatUnitBTextBox.setTitle("Repeat Unit B");
		repeatUnitBCanvas.addChild(repeatUnitBTextBox);
		repeatUnitBTab.setPane(repeatUnitBCanvas);
		Tab tTab4 = new Tab("End Group 1");
		Canvas tab4Canvas = new Canvas();
		tab4Canvas.setBackgroundColor("#F0F0F0");
		final TextBox tbEndGroup1 = new TextBox();
		tbEndGroup1.setTitle("End Group 1");
		tab4Canvas.addChild(tbEndGroup1);
		tTab4.setPane(tab4Canvas);
		Tab tTab5 = new Tab("End Group 2");
		Canvas tab5Canvas = new Canvas();
		tab5Canvas.setBackgroundColor("#F0F0F0");
		final TextBox tbEndGroup2 = new TextBox();
		tbEndGroup2.setTitle("End Group 2");
		tab5Canvas.addChild(tbEndGroup2);
		tTab5.setPane(tab5Canvas);
		Tab tTab6 = new Tab("Build Random Copolymer");
		HLayout horizontalLayout = new HLayout();
		Canvas tab6Canvas = new Canvas();
		tab6Canvas.setBackgroundColor("#F0F0F0");
		//Add a review submission button
		IButton reviewSubmissionButton = new IButton("Review Submission");
		reviewSubmissionButton.setLeft(0);
		reviewSubmissionButton.setHeight(30);
		reviewSubmissionButton.setWidth(150);
		reviewSubmissionButton.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				tbRepeatUnit.setText(callGetData());
				tbEndGroup1.setText(callGetEndGroup1());
				tbEndGroup2.setText(callGetEndGroup2());
				repeatUnitBTextBox.setText(callGetRepeatUnitB());
			}
			
		});
		tab6Canvas.addChild(reviewSubmissionButton);
		//Add a build polymer button
		IButton buildPolymerButton =  new IButton("Build Polymer");
		buildPolymerButton.setLeft(160);
		buildPolymerButton.setHeight(30);
		buildPolymerButton.setWidth(150);
		//Add restlet code here.
		buildPolymerButton.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				double torsionAngle = 0.0;
				counter++;
				int repeatUnitRCount =  countNumberofFragmentPoints(callGetData(),"[Pr]");
				int endGroup1RCount = countNumberofFragmentPoints(callGetEndGroup1(),"[Pr]");
				int endGroup2RCount = countNumberofFragmentPoints(callGetEndGroup2(),"[Pr]");	
				int repeatUnitBRCount = countNumberofFragmentPoints(callGetRepeatUnitB(),"[Pr]");
				if(repeatUnitRCount != 2 || endGroup1RCount != 1 || endGroup2RCount != 1){
					com.google.gwt.user.client.Window.alert("Please check the number of Pr atoms!");
				}
				if(repeatUnitRCount == 2 && repeatUnitBRCount == 2 && endGroup1RCount == 1 && endGroup2RCount == 1){
					com.google.gwt.user.client.Window.alert("Processing polymer!");
					try {
						setpAA(Double.parseDouble(pAATextBox.getText()));
					} catch (NumberFormatException nfe) {
						com.google.gwt.user.client.Window.alert("Probability must be within the range 0< x< 1");
					}
					try{
						setpAB(Double.parseDouble(pABTextBox.getText()));
					}
					catch(NumberFormatException nfe){
						com.google.gwt.user.client.Window.alert("Probability must be within the range 0< x< 1");
					}
					try{
						setpTA(Double.parseDouble(pTATextBox.getText()));
					}
					catch(NumberFormatException nfe){
						com.google.gwt.user.client.Window.alert("Probability must be within the range 0< x< 1");
					}
					try{
						setpBA(Double.parseDouble(pBATextBox.getText()));
					}
					catch(NumberFormatException nfe){
						com.google.gwt.user.client.Window.alert("Probability must be within the range 0< x< 1");						
					}
					try{
						setpBB(Double.parseDouble(pBBTextBox.getText()));
					}
					catch(NumberFormatException nfe){
						com.google.gwt.user.client.Window.alert("Probability must be within the range 0< x< 1");						
					}
					try{
						setpTB(Double.parseDouble(pTBTextBox.getText()));
					}
					catch(NumberFormatException nfe){
						com.google.gwt.user.client.Window.alert("Probability must be within the range 0< x< 1");												
					}
					try {
						torsionAngle = Double.parseDouble(tbTorsionAngle.getText());
						if ((torsionAngle < 0) || (torsionAngle > 360)) {
							throw new NumberFormatException();
						}
					} catch (NumberFormatException nfe1) {
						com.google.gwt.user.client.Window.alert("You need to enter a double for torsion angle and it needs to be within the  range of 0 <= x <= 360");
					}
					//Need to add restlet code here to process the polymer.
					//Replace [Pr] with [R]
					String endGroup1 = callGetEndGroup1().replace("[Pr]", "[R]");
					String repeatUnit = callGetData().replace("[Pr]", "[R]");
					String repeatUnitB = callGetRepeatUnitB().replace("[Pr]", "[R]");
					String endGroup2 = callGetEndGroup2().replace("[Pr]", "[R]");
					
					com.google.gwt.user.client.Window.alert(endGroup1);
					com.google.gwt.user.client.Window.alert(repeatUnit);
					com.google.gwt.user.client.Window.alert(repeatUnitB);
					com.google.gwt.user.client.Window.alert(endGroup2);
					
					final Client client = new Client(Protocol.HTTP);
					Form form = new Form();
					form.add("pAA",pAATextBox.getText());
					form.add("pBA",pBATextBox.getText());
					form.add("pTA",pTATextBox.getText());
					form.add("pAB",pABTextBox.getText());
					form.add("pTB",pTBTextBox.getText());
					form.add("pBB",pBBTextBox.getText());
					form.add("torsionAngle", tbTorsionAngle.getText());
					form.add("endGroup1", endGroup1);
					form.add("repeatUnit", repeatUnit);
					form.add("repeatUnitB",repeatUnitB);
					form.add("endGroup2", endGroup2);
					form.add("counter",Integer.toString(counter));
					Representation rep = form.getWebRepresentation();
					client.post("http://localhost:8080/svc/randomCopolymer", rep, new Callback() {
					
						@Override
						public void onEvent(Request request, Response response) {
							String resultantText = response.getEntity().getText();
							com.google.gwt.user.client.Window.alert(resultantText);
							resultantText = resultantText.replace("\n", "");
							setRandomCopolymerBuilt(resultantText);
							String jmolApplet = " <applet name=\"jmol1\" code=\"JmolApplet\" archive=\"JmolApplet.jar\" width=\"450\" height=\"450\" align=\"right\"> "+
							" <param name = \"progressbar\" value = \"true\"/>"+
							"<param name=\"load\" value=\"RandomCopolymer0.cml\"/> </applet>";
							HTMLFlow jmolHTML = new HTMLFlow();
							jmolHTML.setOverflow(Overflow.AUTO);
							jmolHTML.setPadding(10);
							jmolHTML.setContents(jmolApplet);
							Tab ttt = new Tab("JMOL Result");
							Canvas tab7Canvas = new Canvas();
							tab7Canvas.setBackgroundColor("#F0F0F0");
							tab7Canvas.addChild(jmolHTML);
							ttt.setPane(tab7Canvas);
							randomCopolymerDetails.addTab(ttt);

						}});

			
				}
			}	
		});		
	
		horizontalLayout.addChild(buildPolymerButton);
		tab6Canvas.addChild(buildPolymerButton);
		tab6Canvas.addChild(new HTML("<br></br><br></br>Press the <I>\"Review Submission\"</I> button to check the input before polymerization, then press the <I>\"Build Polymer\"</I> button to build the polymer." +
		"<br></br> Then please visit the visualization panel to view the built polymer."));
		tTab6.setPane(tab6Canvas);
		randomCopolymerDetails.addTab(pAATab);
		randomCopolymerDetails.addTab(pABTab);
		randomCopolymerDetails.addTab(pTATab);
		randomCopolymerDetails.addTab(pBATab);
		randomCopolymerDetails.addTab(pBBTab);
		randomCopolymerDetails.addTab(pTBTab);
		randomCopolymerDetails.addTab(tTab2);
		randomCopolymerDetails.addTab(tTab3);
		randomCopolymerDetails.addTab(repeatUnitBTab);
		randomCopolymerDetails.addTab(tTab4);
		randomCopolymerDetails.addTab(tTab5);
		randomCopolymerDetails.addTab(tTab6);
		return randomCopolymerDetails;

	}

	@Override
	public void setUpPanel() {
		this.setVisibilityMode(VisibilityMode.MULTIPLE);
		this.setWidth(1000);
		this.setHeight(500);
		this.setBorder("2px solid #458B00");
		SectionStackSection section1 = new SectionStackSection("Random Copolymer");
		section1.setExpanded(true);
		HTMLFlow welcome = new HTMLFlow();
		welcome.setOverflow(Overflow.AUTO);
		welcome.setPadding(10);
		String welcomeString = "Welcome to the random copolymer builder panel, please see the instructions tab "+
		"below for more details on what a random copolymer is, and how to build a random copolymer.";
		welcome.setContents(welcomeString);
		section1.addItem(welcome);
		this.addSection(section1);
		this.setStyleName("sectionHeaderclosed");
		this.setBackgroundColor("#F0F0F0");
		//Add drawing panel
		final SectionStackSection drawingPanel = new SectionStackSection("Drawing Panel");
		HTMLFlow drawingPanelInfo = new HTMLFlow();
		drawingPanelInfo.setOverflow(Overflow.AUTO);
		drawingPanelInfo.setPadding(10);
		drawingPanel.setExpanded(false);
		drawingPanel.addItem(jchemPaintPanel());
		this.addSection(drawingPanel);
		//Add homopolymer details panel - submission.
		TabSet details = detailsPanel();
		SectionStackSection infoToSubmit = new SectionStackSection("Submission Details");
		infoToSubmit.setExpanded(false);
		infoToSubmit.addItem(details);
	
		this.addSection(infoToSubmit);
		//Visualization panel
		SectionStackSection visualizationPanel = VisualizationPanel();
		this.addSection(visualizationPanel);
		//Add instructions tab.
		SectionStackSection instructionSection = new SectionStackSection("Instructions");
		instructionSection.setExpanded(false);
		HTMLFlow randomCopolymerInstructions = new HTMLFlow();
		randomCopolymerInstructions.setOverflow(Overflow.AUTO);
		randomCopolymerInstructions.setPadding(10);
		String instructions ="Random copolymers are defined as: A copolymer consisting of alternating segments of two monomeric units of random length, including single molecules.<br></br>"+
		"<b> Instructions</b> <br></br>"+
		"1. Using the drawing panel, you can draw structures of the repeat units A and B and end groups 1 and 2.<br></br>"+
		" <b>Remember</b><br></br> Repeat units have two R groups.<br></br> "+
		"End groups have one R group.<br></br>"+
		"2. <b>Submission Panel</b><br></br>" +
		"The submission panel gives information on the: degree of polymerization, torsion angle and the repeat units and end groups used. To build the random copolymer"+
		" go to the <I>\"Build Random copolymer</I>\" tab and press the build polymer button, this will build your requested polymer.<br></br> "+
		"3. <b>Visualization Panel </b><br></br> Please visit the visualization panel when you have submitted your polymer, as the resultant polymer can be visualized there.<br></br>"+
		"4. <b>Delete Panel</b><br></br> If you are not happy with your selection or choose to build another polymer you can click on the <I>\"Delete Panel\"</I> and press the delete panel button"+
		" this will delete the random copolymer panel, so you can start over again.<br></br>"+
		"<b>Terminology</b><br></br>"+
		"<I>Degree of polymerization</I>:the number of repeat units in an average polymer chain at time t in a polymerization reaction. Ref: http://en.wikipedia.org/wiki/Degree_of_polymerization. Accessed: 09/09/09<br></br>"+
		"<I>Torsion angle</I>: the angle between two planes. Ref: http://en.wikipedia.org/wiki/Dihedral_angle. Accessed: 09/09/09<br></br>"+
		"<I>Repeat unit</I>: the repeat unit is the simplest structural entity of a polymer chain. Ref: http://en.wikipedia.org/wiki/Repeat_unit. Accessed: 09/09/09<br></br>"+
		"<I>End group</I>: is a constitutional unit that is an extremity of a macromolecule or oligomer molecule. Ref: http://en.wikipedia.org/wiki/End-group. Accessed: 09/09/09";
		randomCopolymerInstructions.setContents(instructions);
		instructionSection.addItem(randomCopolymerInstructions);
		this.addSection(instructionSection);
		//Delete panel section
		SectionStackSection deletePanelSection = new SectionStackSection("Delete Panel");
		deletePanelSection.setExpanded(false);
		Button deletePanelButton = new Button("Delete Panel!");
		deletePanelButton.setSize("100", "30");
		deletePanelButton.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				destroy();
			}
		});
	   deletePanelSection.addItem(deletePanelButton);
	   this.addSection(deletePanelSection);

	}
	
	/**
	 * TabSet panel for JChempaint
	 * @return TabSet - tabs containing jchemPaint applets.
	 */
	private TabSet jchemPaintPanel(){
		TabSet drawingPanels = new TabSet();
		drawingPanels.setBackgroundColor("#F0F0F0");
		drawingPanels.setTabBarPosition(Side.TOP);
		drawingPanels.setWidth(1000);
		drawingPanels.setHeight(500);
		//Add separate panes.
		Tab tTab1 = new Tab("Repeat Unit A");
		Canvas tab1Canvas = new Canvas();
		tab1Canvas.setBackgroundColor("#F0F0F0");
		String appletCode = "<br></br>  <applet code=\"org.openscience.cdk.applications.jchempaint.applet.JChemPaintEditorApplet\" archive=\"jchempaint-applet-core.jar\" name=\"applet\" width=\"450\" height=\"375\">"+"</applet>";
		tab1Canvas.setContents(appletCode);
		tTab1.setPane(tab1Canvas);
		//Add repeat unit B tab.
		Tab tTabrepeatUnitB = new Tab("Repeat Unit B");
		Canvas tabrepeatUnitBCanvas = new Canvas();
		tabrepeatUnitBCanvas.setBackgroundColor("#F0F0F0");
		String appletCodeRepeatUnitB = "<br></br>  <applet code=\"org.openscience.cdk.applications.jchempaint.applet.JChemPaintEditorApplet\" archive=\"jchempaint-applet-core.jar\" name=\"repeatUnitB\" width=\"450\" height=\"375\">"+"</applet>";
		tabrepeatUnitBCanvas.setContents(appletCodeRepeatUnitB);
		tTabrepeatUnitB.setPane(tabrepeatUnitBCanvas);
		//Add End Group 1 tab.
		Tab tTab2 =  new Tab("End Group 1");
		Canvas tab2Canvas = new Canvas();
		tab2Canvas.setBackgroundColor("#F0F0F0");
		String endGroup1Applet = "<br></br> <applet code=\"org.openscience.cdk.applications.jchempaint.applet.JChemPaintEditorApplet\" archive=\"jchempaint-applet-core.jar\" name=\"endgroup1\" width=\"450\" height=\"375\">"+"</applet>";
		tab2Canvas.setContents(endGroup1Applet);
		tTab2.setPane(tab2Canvas);
		//Add End Group 2 tab.
		Tab tTab3 = new Tab("End Group 2");
		Canvas tab3Canvas = new Canvas();
		tab3Canvas.setBackgroundColor("#F0F0F0");
		String endGroup2Applet = "<br></br> <applet code=\"org.openscience.cdk.applications.jchempaint.applet.JChemPaintEditorApplet\" archive=\"jchempaint-applet-core.jar\" name=\"endGroup2\" width=\"450\" height=\"375\">"+"</applet>";
		tab3Canvas.setContents(endGroup2Applet);
		tTab3.setPane(tab3Canvas);
		drawingPanels.addTab(tTab1);
		drawingPanels.addTab(tTabrepeatUnitB);
		drawingPanels.addTab(tTab2);
		drawingPanels.addTab(tTab3);
		return drawingPanels;
	}

	/**
	 * Set up the visualization panel, this will involve the use of JMol.
	 * @return SectionStackSection - section for the visualization panel for Jmol.
	 */
	private SectionStackSection VisualizationPanel(){
		SectionStackSection visualizationSection = new SectionStackSection("Visualization Panel");
		visualizationSection.setExpanded(false);
		String jmolApplet = " <applet name=\"jmol\" code=\"JmolApplet\" archive=\"JmolApplet.jar\" width=\"250\" height=\"250\" align=\"right\"> "+
		" <param name = \"progressbar\" value = \"true\"/>"+
		"<param name=\"load\" value=\"RandomCopolymer0.cml\"/> </applet>";
		HTMLFlow jmolHTML = new HTMLFlow();
		jmolHTML.setOverflow(Overflow.AUTO);
		jmolHTML.setPadding(10);
		jmolHTML.setContents(jmolApplet);
		visualizationSection.addItem(jmolHTML);
		String randomCopolymerSourceLink = "<a href=\"http://localhost:8080/RandomCopolymer0.cml\">CML Source</a>";
		HTMLFlow blockCopolymerSource =  new HTMLFlow();
		blockCopolymerSource.setContents(randomCopolymerSourceLink);
		visualizationSection.addItem(blockCopolymerSource);
		return visualizationSection;
	}
	
	/**
	 * Native javascript method to  invoke the DOM and extract smile strings from JchemPaint
	 * @return String representation of the repeat unit.
	 */
	private native String callGetData() /*-{
	   var smileString;
	   smileString = $doc.applet.getSmiles();
	   return smileString;
	    }-*/;
	
	private native String callGetRepeatUnitB() /*-{
		var smileString;
		smileString =  $doc.repeatUnitB.getSmiles();
		return smileString;
	}-*/;
	/**
	 * Native method to return endgroup 1 smile string from JChempaint.
	 * @return String representation of end group1.
	 */
	private native String callGetEndGroup1() /*-{
		var endGroup1;
		endGroup1 = $doc.endgroup1.getSmiles();
		return endGroup1;
		}-*/;
	
	/**
	 * Native method to return endgroup 1 smile string from JChempaint.
	 * @return String representation of end group1.
	 */
	private native String callGetEndGroup2() /*-{
		var endGroup2;
		endGroup2 = $doc.endGroup2.getSmiles();
		return endGroup2;
		}-*/;
	
	/**
	 * This method checks the number of R atoms drawn for the repeat units and end groups in JChempaint.
	 * @param text - R group value [R].
	 * @param search - Smile string to search.
	 * @return - int value representing the number of R groups in a molecule.
	 */
	private int countNumberofFragmentPoints(final String text, final String search){
		 int count = 0;
		 for (int fromIndex = 0; fromIndex > -1; count++){
			 fromIndex = text.indexOf(search, fromIndex + ((count > 0) ? 1 : 0));
		 }   
		    return count - 1;
	}
	/**
	 * @param randomCopolymerBuilt the randomCopolymerBuilt to set
	 */
	public void setRandomCopolymerBuilt(final String randomCopolymerBuilt) {
		this.randomCopolymerBuilt = randomCopolymerBuilt;
	}
	/**
	 * @return the randomCopolymerBuilt
	 */
	public String getRandomCopolymerBuilt() {
		return randomCopolymerBuilt;
	}
	/**
	 * @param pAA the pAA to set
	 */
	public void setpAA(final double pAA) {
		this.pAA = pAA;
	}
	/**
	 * @return the pAA
	 */
	public double getpAA() {
		return pAA;
	}
	/**
	 * @param pAB the pAB to set
	 */
	public void setpAB(final double pAB) {
		this.pAB = pAB;
	}
	/**
	 * @return the pAB
	 */
	public double getpAB() {
		return pAB;
	}
	/**
	 * @param pTA the pTA to set
	 */
	public void setpTA(final double pTA) {
		this.pTA = pTA;
	}
	/**
	 * @return the pTA
	 */
	public double getpTA() {
		return pTA;
	}
	/**
	 * @param pBA the pBA to set
	 */
	public void setpBA(final double pBA) {
		this.pBA = pBA;
	}
	/**
	 * @return the pBA
	 */
	public double getpBA() {
		return pBA;
	}
	/**
	 * @param pBB the pBB to set
	 */
	public void setpBB(final double pBB) {
		this.pBB = pBB;
	}
	/**
	 * @return the pBB
	 */
	public double getpBB() {
		return pBB;
	}
	/**
	 * @param pTB the pTB to set
	 */
	public void setpTB(final double pTB) {
		this.pTB = pTB;
	}
	/**
	 * @return the pTB
	 */
	public double getpTB() {
		return pTB;
	}


}
